<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<!-- JS高级部分深克隆与浅克隆-->
		<script>
			var a = {
				name: "zhangsan",
				age: 18
			};
			var b = a;
			b.name = "lisi";
			console.log(a); //{age:18,name:"lisi"}
			console.log(b); //{age:18,name:"lisi"}

			var c = function() {
				console.log('ccc')
			};
			var d = c;
			d = function() {
				(console.log('ddd'))
			};
			c(); //ccc
			d(); //ddd
			//函数是一等对象，也是对象，比如
			function a() {};
			console.log(a instanceof Object);
			//instanceof函数可以判断左边参数是否是右边参数的一个实例！
			//instanceof运算符用来判断一个构造函数的prototype属性所指向的对象是否存在另外一个要检测对象的原型链上

			function deepClone(arr) {
				if(typeof arr != "object") {
					return arr;
				}
				var result = {};
				for(var i in arr) {
					result[i] = deepClone(arr[i]);
				}
				return result;
			}
			var e = {
				name: "zhangsan",
				age: 18
			};
			var f = deepClone(e);
			f.name = "lisi";
			console.log(e); //{age:18,name:"zhangsan"}
			console.log(f); //{age:18,name:"lisi"}
		</script>
	</body>

</html>